from mmdet.apis import init_detector, inference_detector, show_result_pyplot

config_file = './configs/faster_rcnn_config.py'
# 从 model zoo 下载 checkpoint 并放在 `checkpoints/` 文件下
# 网址为: http://download.openmmlab.com/mmdetection/v2.0/faster_rcnn/faster_rcnn_r50_fpn_1x_coco/faster_rcnn_r50_fpn_1x_coco_20200130-047c8118.pth
checkpoint_file = '/home/ubuntu/code/mmdetection-master/result/faster-rcnn/latest.pth'
device = 'cuda:0'
# 初始化检测器
model = init_detector(config_file, checkpoint_file, device=device)
model.eval()
# 推理演示图像
img = './tongzhou20190822_85_11.jpg'
result = inference_detector(model, img)

show_result_pyplot(model, img, result, score_thr=0.3)